package cn.com.cfae.iras.doc.analyze.parse.kv;


import java.util.ArrayList;
import java.util.List;

public class KVText {

    public KVText() {
        textLayoutList = new ArrayList<>();
    }

    public int getPageNumber() {
        return pageNumber;
    }

    public void setPageNumber(int pageNumber) {
        this.pageNumber = pageNumber;
        if (getTextLayout() != null) {
            getTextLayout().setPageNumber(pageNumber);
        }
    }

    private int pageNumber;

    /**
     * 1、经过处理后的文本，包括换行
     * 2、可能跨越≥1行文本
     */
    private String text;

    private KVType kvType;

    private int seqNo;


    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public KVType getKvType() {
        return kvType;
    }

    public void setKvType(KVType kvType) {
        this.kvType = kvType;
    }

    public int getSeqNo() {
        return seqNo;
    }

    public void setSeqNo(int seqNo) {
        this.seqNo = seqNo;
    }

    public List<TextLayout> getTextLayoutList() {
        return textLayoutList;
    }

    public void setTextLayoutList(List<TextLayout> textLayoutList) {
        this.textLayoutList.addAll(textLayoutList);
    }


    public void add(TextLayout textLayout) {
        if (textLayout == null) {
            return;
        }
        textLayoutList.add(textLayout);
    }

    List<TextLayout> textLayoutList = null;

    @Deprecated
    public Double getTop() {
        return getTextLayout().getTop();
    }

    @Deprecated
    public Double getLeft() {
        return getTextLayout().getLeft();
    }

    @Deprecated
    public Double getWidth() {
        return getTextLayout().getWidth();
    }

    @Deprecated
    public Double getHeight() {
        return getTextLayout().getHeight();
    }

    public TextLayout getTextLayout() {
        return textLayoutList.isEmpty() ? null : textLayoutList.get(0);
    }

}
